<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
    <%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
    <%@page import="Bean.MemberBean" %>

<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<script type="text/javascript" src="/bigjo/js/jquery.js"></script>
<title>Insert title here</title>
</head>
<style type="text/css">
	table{
		margin-top: 50px;
	}
</style>
<script type="text/javascript">
jQuery.noConflict();
jQuery("#m_nicknamechecked").click(function(){
	var idx = document.URL.indexOf("bigjo");
	var str = document.URL.substring(0, idx+5);
	var nickname = jQuery("#m_nickname").val();
	if(nickname == ""){
		alert('닉네임을 우선 입력하세요.');
		jQuery("#m_nickname").val("");
		jQuery("#m_nickname").focus();
		return ;
	}else if(nickname.length <= 3 ){
		alert('아이디는 4자리 이상입니다.');
		jQuery("#m_nickname").focus();
		return ;
	}else{
		jQuery.ajax({
			url : str+"/membernicknameCheck.mb?m_nickname="+nickname,
			contentType : "application/x-www-form-urlencoded; charset=UTF-8",

			success : function(data) {	
				jQuery("#nickresult").html(data);
			},
			error: function(request,status,error){
			alert("code : " + request.status + "\n" + "error : " + error );
			}
			
		});
	}
});
</script>

<script type="text/javascript">
jQuery.noConflict();
	jQuery("#m_emailchecked").click(function(){
		var idx = document.URL.indexOf("bigjo");
		var str = document.URL.substring(0, idx+5);
		var email = jQuery("#m_email").val();
		if(email == ""){
			alert('닉네임을 우선 입력하세요.');
			jQuery("#m_email").val("");
			jQuery("#m_email").focus();
			return ;
		}else{
			jQuery.ajax({
				url : str+"/memberemailCheck.mb?m_email="+email,
				contentType : "application/x-www-form-urlencoded; charset=UTF-8",
	
				success : function(data) {
					jQuery("#emailresult").html(data);
				},
				error: function(request,status,error){
				alert("code : " + request.status + "\n" + "error : " + error );
				}
				
			});
		}
		
	});
	
	jQuery.noConflict();
	jQuery("#update").click(function(){
		var idx = document.URL.indexOf("bigjo");
		var str = document.URL.substring(0, idx+5);
		
		var m_id = jQuery("#m_id").val();
		var m_pw = jQuery("#m_pw").val();

		if(m_pw == null || m_pw == ""){
			alert("패스워드를 입력하세요");
			return;
		}
		var m_nickname = jQuery("#m_nickname").val();
		var m_email = jQuery("#m_email").val();
		var m_ssn1 = jQuery("#m_ssn1").val();
		var m_ssn2 = jQuery("#m_ssn2").val();
		var m_addres = jQuery("#m_addres").val();
		
			location.href = str + "/memberUpdate.mb?m_id="+m_id+"&m_pw="+m_pw+"&m_nickname="+m_nickname+"&m_email="+m_email+"&m_ssn1="+m_ssn1+"&m_ssn2="+m_ssn2+"&m_addres="+m_addres;
	});
	
	jQuery.noConflict();
	jQuery("#cancel").click(function(){
		var idx = document.URL.indexOf("bigjo");
		var str = document.URL.substring(0, idx+5);
		if (confirm("정말 취소하시겠습니까??") == true){    //확인
			location.href= str;
		}else{   //취소
		return;
		}
	});
</script>

<body>
	<table class="updatetb" align="center">	
	<thead>
				<tr>
					<th colspan="7">마이 페이지</th>
				</tr>
	</thead>
	<tbody>
				<tr>
					<td>아이디</td><td align="left"><input type="text" disabled="disabled" id="m_id" name="m_id" value="${myinfo.m_id}"></td>
				</tr>
				<tr>
					<td>패스워드</td><td align="left"><input type="password" id="m_pw" name="m_pw" value=""></td>
				</tr>
				<tr>
					<td>닉네임</td><td align="left"><input type="text" id="m_nickname" name="m_nickname" value="${myinfo.m_nickname }"></td><td><input type="button" id="m_nicknamechecked" value="닉네임체크"></td>
				</tr>
				<tr><td></td><td ><span id="nickresult"></span></td></tr>
				<tr>
					<td>이메일</td><td align="left"><input type="text" id="m_email" name="m_email" value="${myinfo.m_email}"></td><td><input type="button" id="m_emailchecked" value="이메일체크"></td>
				</tr>
				<tr><td></td><td ><span id="emailresult"></span></td></tr>
				<tr>
					<td>주민등록 번호</td><td align="left"><input type="text" id="m_ssn1" name="m_ssn1"  maxlength="6" size="6" value="${myinfo.m_ssn1}">-<input type="password" id="m_ssn2" name="m_ssn2"  maxlength="7" size="7" value="${myinfo.m_ssn2}"></td>
				</tr>
				<tr>
					<td>주소</td><td align="left"><input type="text" id="m_addres" name="m_addres" value="${myinfo.m_addres}"></td>
				</tr>
				<tr><td></td><td><input type="button" id="update" value="수정"><input type="button" id="cancel" value="취소"></td></tr>
	</tbody>
	</table>
	
</body>
</html>